import fs from 'fs-extra'

const dir = `temp/8f719338b54198a5020d16284108745ef69aafb0f895c75c9d27e2e1387af7f7.mp4`

const t1 = async () => {
  try {
    // 判断文件路径是否存在
    let r = await fs.pathExists(dir)
    // true
    console.log(r);
  } catch (error) {

  }
}

const t2 = async () => {
  try {
    let d = await fs.pathExists('testsss')
    // false
    console.log(d);
  } catch (error) {
  }
}

const readDir = async () => {
  try {


    let r = await fs.readdir(dir)
    // 读取分片
    /**
      [
      '0-8f719338b54198a5020d16284108745ef69aafb0f895c75c9d27e2e1387af7f7.mp4',
      '1-8f719338b54198a5020d16284108745ef69aafb0f895c75c9d27e2e1387af7f7.mp4',
      '2-8f719338b54198a5020d16284108745ef69aafb0f895c75c9d27e2e1387af7f7.mp4',
      '3-8f719338b54198a5020d16284108745ef69aafb0f895c75c9d27e2e1387af7f7.mp4',
      '4-8f719338b54198a5020d16284108745ef69aafb0f895c75c9d27e2e1387af7f7.mp4',
      '5-8f719338b54198a5020d16284108745ef69aafb0f895c75c9d27e2e1387af7f7.mp4',
      '6-8f719338b54198a5020d16284108745ef69aafb0f895c75c9d27e2e1387af7f7.mp4',
      '7-8f719338b54198a5020d16284108745ef69aafb0f895c75c9d27e2e1387af7f7.mp4',
      '8-8f719338b54198a5020d16284108745ef69aafb0f895c75c9d27e2e1387af7f7.mp4'
    ]
     */
    console.log(r);
  } catch (error) {
    // 如果文件夹不存在，则这里会有异常
    console.log(error);
  }

}

readDir()